<%@page import="com.fractalist.man.constants.ManConstants"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp"%>
<%
	pageContext.setAttribute("userTypeMap", ManConstants.USER_TYPE_MAP);
	pageContext.setAttribute("userStateMap",
			ManConstants.USER_STATE_MAP);
	pageContext.setAttribute("userGenderMap",
			ManConstants.USER_GENDER_MAP);
	pageContext.setAttribute("bangdanTypeMap",
			ManConstants.BANGDAN_TYPE_MAP2);
	pageContext.setAttribute("bangdanPerMap",
			ManConstants.BANGDAN_PER_MAP);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>装女郎列表</title>
<link rel="stylesheet" href="${ctx }/css/styles.css" type="text/css" />
<script type="text/javascript" src="${ctx }/js/jquery-1.6.1.min.js"></script>
<jsp:include page="/common/jscalendar.jsp"></jsp:include>
<style>
.tc a {
	color: red;
}
</style>
<script type="text/javascript">
	var pageNo = 1;
	var pageSize = 10;
	var pageCount = 0;

	$(function() {

		$("#table_wrapper").height($(window).height() - 40);

		//翻页
		$("#home").click(function() {
			if (pageNo != 1) {
				pageNo = 1;
				queryHandle(pageNo);
			}
		});
		$("#last").click(function() {
			if (pageNo != pageCount) {
				pageNo = pageCount;
				queryHandle(pageNo);
			}
		});
		$("#previous").click(function() {
			if (pageNo != 1) {
				pageNo--;
				queryHandle(pageNo);
			}
		});
		$("#next").click(function() {
			if (pageNo != pageCount) {
				pageNo++;
				queryHandle(pageNo);
			}
		});
		$("#jump").click(function() {
			var jumpValue = $("#currentPage").val();
			if (parseInt(jumpValue) > pageCount || parseInt(jumpValue) < 1) {
				alert("跳转页码输入有误！");
				return;
			}
			pageNo = parseInt(jumpValue);
			queryHandle(pageNo);
		});

		queryHandle(1);
	});

	var userTypeMap = {};
	<c:forEach items="${userTypeMap}" var="entry">
	userTypeMap["${entry.key}"] = "${entry.value}";
	</c:forEach>
	var userStateMap = {};
	<c:forEach items="${userStateMap}" var="entry">
	userStateMap["${entry.key}"] = "${entry.value}";
	</c:forEach>
	var userGenderMap = {};
	<c:forEach items="${userGenderMap}" var="entry">
	userGenderMap["${entry.key}"] = "${entry.value}";
	</c:forEach>
	var bangdanTypeMap = {};
	<c:forEach items="${bangdanTypeMap}" var="entry">
	bangdanTypeMap["${entry.key}"] = "${entry.value}";
	</c:forEach>
	var bangdanPerMap = {};
	<c:forEach items="${bangdanPerMap}" var="entry">
	bangdanPerMap["${entry.key}"] = "${entry.value}";
	</c:forEach>

	function undisableUser(userId) {
		$.post("${ctx}/manage/undisableUser.action?userId=" + userId, {},
				function(data) {
					data = eval("(" + data + ")");
					if (data.state != 0) {
						alert(data.msg);
					} else {
						alert(data.msg);
						location.href = "${ctx}/manager/viewUserPage.action";
					}
				});
	}

	function disableUser(userId) {
		$.post("${ctx}/manage/disableUser.action?userId=" + userId, {},
				function(data) {
					data = eval("(" + data + ")");
					if (data.state != 0) {
						alert(data.msg);
					} else {
						alert(data.msg);
						location.href = "${ctx}/manager/viewUserPage.action";
					}
				});
	}

	function freezeScore(userId) {
		$.post("${ctx}/manage/freezeScore.action?userId=" + userId, {},
				function(data) {
					data = eval("(" + data + ")");
					if (data.state != 0) {
						alert(data.msg);
					} else {
						alert(data.msg);
						location.href = "${ctx}/manager/viewUserPage.action";
					}
				});
	}

	function unfreezeScore(userId) {
		$.post("${ctx}/manage/unfreezeScore.action?userId=" + userId, {},
				function(data) {
					data = eval("(" + data + ")");
					if (data.state != 0) {
						alert(data.msg);
					} else {
						alert(data.msg);
						location.href = "${ctx}/manager/viewUserPage.action";
					}
				});
	}

	function applyGirl(applyId) {
		$
				.post(
						"${ctx}/manage/applyUser.action?applyId=" + applyId,
						{},
						function(data) {
							data = eval("(" + data + ")");
							if (data.state != 0) {
								alert(data.msg);
							} else {
								alert(data.msg);
								location.href = "${ctx}/manager/viewUserZhuangnvlangApplyPage.action";
							}
						});
	}

	function unapplyGirl(applyId) {
		$
				.post(
						"${ctx}/manage/unapplyUser.action?applyId=" + applyId,
						{},
						function(data) {
							data = eval("(" + data + ")");
							if (data.state != 0) {
								alert(data.msg);
							} else {
								alert(data.msg);
								location.href = "${ctx}/manager/viewUserZhuangnvlangApplyPage.action";
							}
						});
	}

	function queryHandle(pageNo) {
		$("#listData").html("");
		$
				.post(
						"${ctx}/manager/mUserZhuangnvlangApplyPage.action?rnd="
								+ Math.random(),
						{
							pageNumber : pageNo,
							pageLine : pageSize,
							girlCity : $("#girlCity").val(),
							name : $("#name").val()
						},
						function(data) {
							data = eval("(" + data + ")");
							var allSize = data.totalCount;
							pageCount = Math.ceil(allSize / pageSize);
							$("#pageCount").html(pageCount);
							$("#allSize").html(allSize);
							$("#currentPage").val(pageNo);
							var listData = "";
							$
									.each(
											data.list,
											function(i, item) {
												var btnStr = "<a onclick='applyGirl("
														+ item.id
														+ ")' href='javascript:void(0);'>通过申请</a>&nbsp;"
														+ "<a onclick='unapplyGirl("
														+ item.id
														+ ")' href='javascript:void(0);'>拒绝申请</a>&nbsp;";
												if (item.state == 1) {
													btnStr = "已通过审核";
												}
												if (item.state == 2) {
													btnStr = "已拒绝通过审核";
												}

												listData += "<tr><td class='tc'>"
														+ item.name
														+ "</td><td class='tc'>"
														+ item.girlCity
														+ "</td><td class='tc'>"
														+ item.age
														+ "</td><td class='tc'>"
														+ item.bwh
														+ "</td><td class='tc'>"
														+ item.constellation
														+ "</td><td class='tc'><img width='100' src='"
														+ item.iconUrl
														+ "'/></td><td class='tc'><img width='100' src='"
														+ item.imageUrl
														+ "'/></td><td class='tc'>"
														+ btnStr + "</td></tr>";
											});
							$("#listData").html(listData);
						});
	}

	function notNull(obj) {
		return obj ? obj : '';
	}

	function nullRate(obj) {
		return obj ? obj + '%' : '';
	}
</script>
</head>
<body>
	<div id="wrapper">
		<div id="content_wrap">
			<div class="tabs_content">
				<div class="active_tab" id="tab1">
					<div class="toolbar2">
						地区： <input id="girlCity" />&nbsp; 昵称： <input id="name" />&nbsp;
						<a href="javascript:void(0);" onclick="queryHandle(1);"
							class="button">检索</a>&nbsp;
					</div>
					<div id="table_wrapper" style="width: 100%; overflow: auto;">
						<table class="table" cellpadding="0" cellspacing="0">
							<thead>
								<tr>
									<th><b>昵称</b></th>
									<th><b>地区</b></th>
									<th><b>年龄</b></th>
									<th><b>三围</b></th>
									<th><b>星座</b></th>
									<th><b>头像照片</b></th>
									<th><b>全屏照片</b></th>
									<th><b>操作</b></th>
								</tr>
							</thead>
							<tbody id="listData">
							</tbody>
							<tfoot>
								<tr>
									<td colspan="10" style="border: 0px; padding-top: 3px;"><a
										id="home" href="javascript:void(0);" class="button1">首页</a> <a
										id="previous" href="javascript:void(0);" class="button1">上一页</a>
										<a id="next" href="javascript:void(0);" class="button1">下一页</a>
										<a id="last" href="javascript:void(0);" class="button1">末页</a>
										&nbsp;&nbsp;&nbsp;第<input id="currentPage" type="text"
										style="width: 20px; text-align: center;" />页 <a id="jump"
										href="javascript:void(0);" class="button" style="width: 50px;">跳转</a>
										&nbsp;&nbsp;&nbsp;共<span id="pageCount"></span>页<span
										id="allSize"></span>条</td>
								</tr>
							</tfoot>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>

